package com.loooooo.pm2024.data;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.loooooo.pm2024.config.BigIDSerialize;
import com.loooooo.pm2024.modules.sys.model.PrettyUser;
import com.loooooo.pm2024.modules.sys.model.User;

import java.io.Serializable;
import java.util.Objects;

public class BaseEntity implements Serializable {
    @JsonSerialize(using = BigIDSerialize.class)
    private Long id;
    protected Long createdAt;
    @JsonSerialize(using = BigIDSerialize.class)
    protected Long createdBy;
    protected Long updatedAt;
    @JsonSerialize(using = BigIDSerialize.class)
    protected Long updatedBy;


    private PrettyUser createdByUser;
    private PrettyUser updatedByUser;

    public PrettyUser getCreatedByUser() {
        return createdByUser;
    }

    public void setCreatedByUser(PrettyUser createdByUser) {
        this.createdByUser = createdByUser;
    }

    public PrettyUser getUpdatedByUser() {
        return updatedByUser;
    }

    public void setUpdatedByUser(PrettyUser updatedByUser) {
        this.updatedByUser = updatedByUser;
    }
    private Integer status;
    private String shape;
    protected Integer deleted;
    private Boolean isNew;
    //主要用在级联修改的时候指示作用。
    private Boolean sysModified;

    public Long getId() {
        return id;
    }

    public BaseEntity setId(Long id) {
        this.id = id;
        return this;
    }

    public Long getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(Long createdAt) {
        this.createdAt = createdAt;
    }

    public Long getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(Long createdBy) {
        this.createdBy = createdBy;
    }

    public Long getUpdatedAt() {
        return updatedAt;
    }

    public void setUpdatedAt(Long updatedAt) {
        this.updatedAt = updatedAt;
    }

    public Long getUpdatedBy() {
        return updatedBy;
    }

    public void setUpdatedBy(Long updatedBy) {
        this.updatedBy = updatedBy;
    }

    public Integer getStatus() {
        return status;
    }

    public BaseEntity setStatus(Integer status) {
        this.status = status;
        return this;
    }

    public Integer getDeleted() {
        return deleted;
    }

    public void setDeleted(Integer deleted) {
        this.deleted = deleted;
    }

    public Boolean getNew() {
        return isNew;
    }

    public boolean isNewEntity() {
        return Objects.equals(Boolean.TRUE, isNew);
    }

    public void setNew(Boolean aNew) {
        isNew = aNew;
    }


    public Boolean getSysModified() {
        return sysModified;
    }

    public void setSysModified(Boolean sysModified) {
        this.sysModified = sysModified;
    }

    public String getShape() {
        return shape;
    }

    public void setShape(String shape) {
        this.shape = shape;
    }

    public boolean idAvailable() {
        return id != null && id > 0;
    }
}
